import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;

import stub.Product;


public class Order{
	
	private boolean						orderSecured;
	private String						customerName;
	private HashMap<Product, Integer>	products;
	
	
	public Order( String customerName ) {
		this.customerName = customerName;
		products = new HashMap<Product, Integer>();
	}
	
	
	public void addProduct( Product p, int amount ) {
		if(products.containsKey( p )){
			products.put( p, products.get( p )+ amount );
		}else{
			products.put( p, amount );
		}
	}
	
	public String getCustomerName(){
		return customerName;
	}
	
	public boolean secured(){
		return orderSecured;
	}
	
	public double getTotalPrice() throws RemoteException {
		double price = 0;
		products.values();
		for( Product p : products.keySet() ){
			price += p.getPrice() * products.get( p );
		}
		return price;
	}
	
	
	public HashMap<Product, Integer> getProductsOverview() {
		return products;
	}
	
	
	public boolean orderSecured(){
		orderSecured = true;
		return orderSecured;
	}
}
